#include <iostream>
#include "s-clique_free.cpp"
#include "IO.cpp"
#include <vector>
#include <boost/dynamic_bitset.hpp>
#include <string>
using namespace std;

/**
 * Szabó Sándor klikk kereső programjával ellenőrzi,
 * hogy a kapott színosztályok valóban s-klikk mentesek-e
 * @param graph
 * @param colorclasses
 * @param s
 * @return
 */
bool checkout_szabo(vector<dynamic_bitset<> > graph, vector<dynamic_bitset<> > colorclasses, int s)
{
    int size = colorclasses.size();
    bool fail = false;
    for(int i = 0; i < size; ++i) {
        if( k_clique( stretch_graph(graph, colorclasses[i]), s ) == true ) {
            cout<<"It's not "<<s<<" clq free: "<<i<<endl;
            fail = true;
        }
    }
    return fail;
}

/**
 * A saját klikk keresőnkkel ellenőrzi, hogy a kapott színosztályok valóban s-klikk mentesek-e
 * @param graph
 * @param colorclasses
 * @param s
 * @return
 */
bool checkout(vector<dynamic_bitset<> > graph, vector<dynamic_bitset<> > colorclasses, int s)
{
    /**
     * @var size - a színosztályok mérete
     */
    int size = colorclasses.size();
    bool fail = false;
    dynamic_bitset<> temp(graph.size());
    temp.set();
    for(int i = 0; i < size; ++i) {
        if( clq_search( stretch_graph(graph, colorclasses[i]), temp, s ) == true ) {
            cout<<"It's not "<<s<<" clq free: "<<i<<endl;
            fail = true;
        }
    }
    return fail;
}

int main(int argc, char** argv)
{

    if(argc != 3) {
        cout<<"Usage: ./filename 'graph_name' s - int"<<endl;
        return 0;
    }

    int s = atoi(argv[2]);

    if(s < 2) {
        cout<<"s must be an positive integer!"<<endl;
        return 0;
    }

    string filename( argv[1] );

    int nodes, edges;
    vector<dynamic_bitset<> > graph;
    readgraph_bitset(filename, graph, nodes, edges);
    vector<dynamic_bitset<> > colorclasses;
    loadcolors(colorclasses, filename, s, nodes);

    cout<<"checkout: ...";
    cout<<(checkout(graph, colorclasses, s) ? "" : "...ok" )<<endl;

    cout<<"checkout szabo: ...";
    cout<<(checkout_szabo(graph, colorclasses, s) ? "" : "...ok" )<<endl;

    return 0;
}
